<?php

class ZhuantiController extends Zend_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
    	$this->view->headLink()->appendStylesheet($this->view->baseUrl().'/css/zhuanti.css');
    }

    public function indexAction()
    {
        $db_zhuanTi=new Application_Model_DbTable_Zhuanti();
        $zhuanTiList=$db_zhuanTi->getAllZhuanTi()->toArray();
        $config=new Zend_Config_Ini(APPLICATION_PATH."/configs/application.ini",'production');
		$db = Zend_Db::factory($config->resources->db);
		$utilZhuanTi=new Txy_Util_ZhuanTi();
        foreach ($zhuanTiList as &$zhuanTi){
        	$utilZhuanTi->getZhuanTiDetail($zhuanTi, $db, 6);
        }
        $this->view->zhuanTiList=$zhuanTiList;
        $this->view->sideBar=1;
        //边栏热门文章列表
		$articleModel=new Application_Model_DbTable_Article();
		$this->view->hotArticles=$articleModel->getHotArticle(15);
		//边栏热门商品列表
		$itemsModel=new Application_Model_DbTable_TaobaoItems();
		$this->view->hotItems=$itemsModel->getSidebarHotItems();
		//热门关键词
		$keywordsModel=new Application_Model_DbTable_Keywords();
		$this->view->keyWordsList=$keywordsModel->getHotKeyWords();
    }
    
    public function contentAction(){
    	
    	$id=(int)$this->getRequest()->getParam('id');
    	$dbZhuanTi=new Application_Model_DbTable_Zhuanti();
    	$zhuanTi=$dbZhuanTi->getZhuanTiById($id)->toArray();
    	$config=new Zend_Config_Ini(APPLICATION_PATH."/configs/application.ini",'production');
		$db = Zend_Db::factory($config->resources->db);
		$utilZhuanTi=new Txy_Util_ZhuanTi();
    	$utilZhuanTi->getZhuanTiDetail($zhuanTi, $db);
    	
    	//设置title
		$this->view->headTitle($zhuanTi['name']);
		//设置关键词（seo）
		$this->view->headMeta()->appendName('keywords', $zhuanTi['key_words']);
		//设置描述（seo）
		$this->view->headMeta()->appendName('description',$zhuanTi['description']);
    	
    	$this->view->zhuanTi=$zhuanTi;
		
    	$this->view->sideBar=1;
        //边栏热门文章列表
		$articleModel=new Application_Model_DbTable_Article();
		$this->view->hotArticles=$articleModel->getHotArticle(15);
		//边栏热门商品列表
		$itemsModel=new Application_Model_DbTable_TaobaoItems();
		$this->view->hotItems=$itemsModel->getSidebarHotItems();
		//热门关键词
		$keywordsModel=new Application_Model_DbTable_Keywords();
		$this->view->keyWordsList=$keywordsModel->getHotKeyWords();
    }
    
   


}

